package ch02_data.generics.typeclear;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 泛型摩擦
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
public class GenericsClear {
    // 泛型摩擦体现
    @Test
    public void test01() {
        List<String> gene01 = new ArrayList<>();
        List<Integer> gene02 = new ArrayList<>();
        System.out.println(gene01.getClass().getName());
        System.out.println(gene02.getClass().getName());
        System.out.println(gene01.getClass() == gene02.getClass());
        // getTypeParameters返回泛型声明对应的类型参数
        System.out.println(Arrays.toString(gene01.getClass().getTypeParameters()));
        System.out.println(Arrays.toString(gene02.getClass().getTypeParameters()));
    }

    @Test
    public void test02() {
        Object a = null;
        String s = null;
        a = s;

        Object[] os = new Object[]{};
        String[] ss = new String[]{};
        os = ss;

        List<Object> oo = null;
        List<String> ls = null;
        // oo = ls;

        List<String> lss = new ArrayList<>();
    }
}
